app.controller("baseController",function($scope){
    $scope.selectedIds=[];//存放 所勾选的ID
    $scope.updateSelection = function($event,id){
        // $event.target.checked   事件冒泡
        if($event.target.checked){
            // true
            $scope.selectedIds.push(id);
        }else {
            // false
            var idIndex = $scope.selectedIds.indexOf(id);
            $scope.selectedIds.splice(idIndex,1);
        }
    }


    $scope.reloadList = function(){
        $scope.search($scope.pageModel.currentPage,$scope.pageModel.itemsPerPage);
    }
    $scope.pageModel = {
        currentPage: 1,
        totalItems: 10,
        itemsPerPage: 10,
        perPageOptions: [5, 10, 15, 40, 50],
        onChange: function(){
            $scope.reloadList();
        }
    }
    $scope.jsonToStr = function(str,keyName){
        var attrArray = JSON.parse(str);
        var resultStr = "";
        for(var i=0;i<attrArray.length;i++){
            if(i==0){
                resultStr += attrArray[i][keyName]
            }else {
                resultStr += ","+attrArray[i][keyName]
            }
        }
        return resultStr;
    }
});